package com.atguigu.generic;

public class GenericDemo {
    public <T> T getObject(Class<T> clazz) throws Exception{
        T t = clazz.newInstance();
        return t;
    }
    public static void main(String[] args) throws Exception {
        GenericDemo genericDemo = new GenericDemo();

        Phone phone = (Phone) genericDemo.getObject(Class.forName("com.atguigu.generic.Phone"));
        phone.setId(1);
        phone.setBrand("vivo");
        phone.setPrice(5999);
        System.out.println("phone = " + phone);

    }
}

